{extend name="common/base" /}

{block name="title"}开通题库{/block}

{block name="body"}
<div class="Hui-admin-article">
    <nav class="breadcrumb" style="background-color:#fff;padding: 0 24px">
        首页
        <span class="c-gray en">/</span>
        用户管理
        <span class="c-gray en">/</span>
        开通题库
    </nav>

    <article class="Hui-admin-content clearfix">

        <div class="panel mt-20">
            <div class="panel-body">
                <form class="row clearfix">
                    <div class="col-xs-12 col-sm-6 col-md-4">
                        <div class="row clearfix mb-10">
                            <span class="col-xs-4 form-item-label">题库名称：</span>
                            <span class="col-xs-8 form-item-control">
                                <input type="text" name="title" value="{$search.cate_title}" id="search-input" placeholder=" 名称" class="input-text" />
                            </span>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-6 col-md-4">
                        <div class="row clearfix">
                            <span class="col-xs-4 form-item-control">
                                <button name="" id="search-submit" class="btn btn-success radius" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜题库</button>
                            </span>
                        </div>
                    </div>
                </form>
            </div>
            <div class="panel-body">
                <div class="clearfix">
                    <span class="f-r">共有数据：<strong>{$count}</strong> 条</span>
                </div>
                <div class="mt-20 clearfix">
                    <table class="table table-border table-bordered table-bg table-hover table-sort">
                        <thead>
                            <tr>
                                <th scope="col" colspan="10">题库列表</th>
                            </tr>
                            <tr class="text-c">
                                <!--<th width="25"><input type="checkbox" name="all" value=""></th>-->
                                <th width="40">ID</th>
                                <th width="150">题库名称</th>
                                <th width="50">是否开通</th>
                                <th width="100">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {foreach name="list" key="k" item="v"}
                            <tr class="text-c">
                                <!--<td><input name="list_box" type="checkbox" value="{$v.id}" ></td>-->
                                <td>{$v.id}</td>
                                <td>{$v.cate_title}</td>
                                <td>{if $v.is_open==0}
                                    未开通
                                    {else/}
                                    已开通
                                    {/if}
                                </td>
                                <td class="td-manage">
                                    <a href="javascript:;" onclick="openQuestion({$v.id})" class="btn btn-primary radius">开通题库</a>
                                </td>
                            </tr>
                            {/foreach}
                            
                        </tbody>
                    </table>
                    
                    {$page|raw}
                </div>
            </div>
        </div>
    </article>
</div>
<input name="mid" type="hidden" value="{$mid}" id="mid">

{/block}


{block name="js"}
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__LIB__/datatables/1.10.15/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__LIB__/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="__JS__/main.js"></script>
<script type="text/javascript">
    $(function(){
        runDatetimePicker();
    });
    function openQuestion(id) {
        var uid = $('#mid').val();
        layer.confirm('确认要开通吗吗？',function(index){
            //此处请求后台程序，下方是成功后的前台处理……
            $.ajax({
                url : "{:url('member/openQuestion')}",
                type : 'post',
                dataType : 'json',
                data : { id:id, uid:uid },
                success : function(ret){
                    if(ret.code == 0){
                        layer.msg('开通成功!', {icon: 6,time:1000});
                        setTimeout(function () {
                            location.reload();
                        },1000)
                    }else{
                        layer.msg(ret.msg,{icon: 2,time:1000});
                    }
                }
            });

        });

    }
</script>
<!--/请在上方写此页面业务相关的脚本-->
{/block}

